<template>
    <div class="editForm-wrapper">
        <!-- 客户编辑dialog-->
        <el-dialog
            :title="title"
            :close-on-click-modal="false"
            v-dialogDrag
            :visible.sync="editVisible"
        >
            <el-form
                label-width="127px"
                ref="editForm"
                :disabled="editForm.flowStateus===2&&editForm.taskKey!=='UserUpdate'"
                :model="editForm"
            >
                <el-form-item label="业务编号:" prop="codes">
                    <el-input v-model="editForm.codes" :disabled="true"></el-input>
                </el-form-item>
                <el-form-item label="客户名称:" prop="companyName">
                    <el-input v-model="editForm.companyName" :disabled="true"></el-input>
                </el-form-item>
                <el-form-item label="产品名称:" prop="productName">
                    <!--          <el-input v-model="editForm.productName" :disabled="true"></el-input>-->
                    <el-select clearable v-model="editForm.productName" disabled placeholder="请选择产品">
                        <!--            <el-option-->
                        <!--              v-for="item in editForm.selectVos"-->
                        <!--              :key="item.value"-->
                        <!--              :label="item.label"-->
                        <!--              :value="item.value">-->
                        <!--            </el-option>-->
                    </el-select>
                </el-form-item>

                <el-form-item label="调整价格:" prop="newPrice" :rules="[
                  {required: true, message:'请输入调整价格', trigger:'blur'},
                  {validator:onlyNumber, trigger:'blur'}
                 ]">
                    <el-input :disabled="method==='info'"   v-thousands.newPrice="editForm" v-model="editForm.newPrice" @change="ss1"></el-input>
                </el-form-item>
                <el-form-item label="支付方式:" prop="payMode" :rules="[
                  {required: true, message:'请选择支付方式', trigger:'blur'}
                 ]">
                    <el-select clearable v-model="editForm.payMode"  :disabled="method==='info'" placeholder="请选择支付方式">
                        <el-option
                            v-for="item in  $dictUtils.getDictList('payMode')"
                            :key="item.value"
                            :label="item.label"
                            :value="Number(item.value)">
                        </el-option>
                    </el-select>
                </el-form-item>

                <el-form-item label="开始执行时间:" prop="effectTime"
                              :rules="[
                  {required: true, message:'请输入开始执行时间', trigger:'blur'}
                 ]">
                    <el-date-picker
                        v-model="editForm.effectTime"
                        type="datetime"
                        :disabled="method==='info'"
                        value-format="yyyy-MM-dd HH:mm:ss"
                        placeholder="选择日期时间"
                    >
                    </el-date-picker>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
        <el-button size="small" :disabled="editForm.flowStateus===2" type="primary" @click="doSubmit(false)"
                   v-noMoreClick>确定</el-button>
        <el-button size="small" :disabled="editForm.flowStateus===2&&editForm.taskKey!=='UserUpdate'" type="warning"
                   @click="doSubmit(true)" v-noMoreClick>提交</el-button>
        <el-button size="small" @click="close()">取消</el-button>
      </span>
        </el-dialog>
    </div>
</template>
<script>
    import {saveAdjust} from '@/api/business/business.js'

    export default {
        components: {},
        data() {
            return {
                areaLabel: {},
                method: '',
                title: '',
                taskDefinitionKey: '',
                editForm: {
                    id: '',
                    flowStateus: '',
                    taskKey: '',
                    businessId: '',
                    productId: '',
                    payMode: 0,
                    selectVos: [],
                    companyName: '',
                    productName: '',
                    codes: '',
                    effectTime: '',
                    newPrice: ''
                },
                editVisible: false,
                detailsVisible: false,
                dataRule: {
                    contactName: [{required: true, message: '请输入客户名称', trigger: 'blur'}],
                    // productName: [
                    //   { required: true, message: '请选择产品类型', trigger: 'change' }
                    // ],
                    creditQuatity: [
                        {required: false, message: '请输入信用量', trigger: 'blur'}
                    ]
                },
                tableData1: [],
                page: {
                    pageSize: 10,
                    pageNo: 1,
                    total: 0
                },
                props: 1,
                dialogVisible: false,
                query: ''
            }
        },
        methods: {
        	handleClose(done) {
        		done()
//				this.$Msg.confirm({
//					title:'您确定要关闭吗？',
//					content:this.GLOBAL.FORM_CLOSE_TIPS,
//					confirmCall:()=>{
//						done();
//					}
//				})
			},
      ss1(e){
        console.log(e)
      },
            select(e) {
                this.editForm.companyName = e.names
                this.editForm.companyId = e.id
                this.dialogVisible = false
                console.log(e)
            },
            onlyNumber(rule, value, callback) {
                if (value && !(/^[1-9]\d*$/).test(value)) {
                    callback(new Error('只能填写正整数'))
                } else {
                    callback()
                }
            },
            init(method, editForm) {
                this.method = method
                console.log(this.method)
                this.editVisible = true
                this.$nextTick(() => {
                    this.$refs.editForm.resetFields()
                    this.editForm = editForm
                })
                this.title = '销售调价'
            },
            getArea1(e) {
                if (e.province !== '' && e.city !== '' && e.district !== '') {
                    this.editForm.countyCode = JSON.stringify(e)
                } else {
                    this.editForm.countyCode = ''
                }
            },
            close() {
                this.editVisible = false
            },
            doSubmit(isFlowable) {
                this.$set(this.editForm, 'isFlowable', isFlowable)
                this.$refs['editForm'].validate((valid) => {
                    if (valid) {
                        this.$set(this.editForm, 'processType', 1)
                        saveAdjust(this.editForm).then((res) => {
                            if (res.data.code === '200') {
                                this.$message({
                                    message: '编辑成功',
                                    type: 'success'
                                })
                                this.editVisible = false
                                this.$emit('refreshDataList')
                            }
                        })
                    }
                })
            }
        },
        mounted() {
            // this.getList(this.page, 1)
        }
    }
</script>
<style lang="scss" scoped>
    .view-container {
        margin-bottom: 20px;
        display: flex;

        .label-container {
            width: 150px;
            text-align: right;
            font-size: 16px;
            font-weight: 400;
            color: #666666;
        }

        .form-container {
            font-size: 14px;
            font-weight: 400;
            color: #333333;
            width: 200px;
        }
    }
</style>
